<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@page import="java.io.*" %>
     <%@page import="mavenWebProject.userMapper" %>
     <%@page import="mavenWebProject.user" %>
     <%@page import="mavenWebProject.productsMapper" %>
     <%@page import="mavenWebProject.products" %>
     <%@page import="mavenWebProject.order" %>
     <%@page import="mavenWebProject.car" %>
     <%@page import="java.util.*" %>
     <%@page import="javax.servlet.*" %>
     <%@page import="org.apache.ibatis.io.Resources" %>
     <%@page import="org.apache.ibatis.session.SqlSession"%>
     <%@page import="org.apache.ibatis.session.SqlSessionFactory" %>
     <%@page import="org.apache.ibatis.session.SqlSessionFactoryBuilder" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员</title>
</head>

<style>
    body{font-family: 楷体;font-size: 18px;}

    table[id="tableGuide"]{
        position: absolute;
        top:0%;
        left:0%;
        width:100%;
        height:200px;
        background-color: black;
        color:white;
    }

    table[id="tableProductsManage"]{position: absolute;top:60px;left:0px;background-color:rgb(241,245,251);width:100%;height:700px;border-top-left-radius: 10px;border-top-right-radius: 10px;}
    
    a:link{color:white;text-decoration:none;padding:10px;}
    a:hover{padding:8px;border-radius: 5px;background-color:aliceblue;color:black;}
    a:visited{color:white;}
    a[id="manageProducts"]{color:white;}
    a[id="manageProducts"]:hover{color:black;}
    a[id="tableProductsManageSearchButton"]{margin-left:20px;padding:8px;background-color:white;border-radius:8px;}
	label{margin-right:15px;}
	
	
    p{margin:0px;}
</style>

<body>
    
    <%
    String username=String.valueOf(session.getAttribute("username"));
    %>
    
    <table id="tableGuide" border="0" cellspacing="10px">
        <tr></tr>
		 <tr><td width="30px"></td><td width="60px"><a href="managerScene.jsp">首页</a></td><td width="100px"><a id="hrefa" href="managerManageProducts.jsp">商品管理</a></td><td width="100px"><a id="hrefa" href="managerManageOrder.jsp">订单管理</a></td><td width="100px"><a id="hrefa" href="managerShowSold.jsp">销量排行</a></td><td width="100px"><a id="hrefa" href="managerManagePurchaser.jsp">用户情况</a></td><td width="100px"></td><td align="right" width="800px">欢迎您：<font style="font-size:24px;margin:10px;color:cyan;"><%=username%></font>&nbsp;&nbsp;<a style="color:red" onClick="exit()">注销</a></td></tr>
		 <tr><td colspan="8" height="150px"></tr>
    </table>
    <script>

        function exit(){document.location.href="loadIn.jsp";}

    </script>

	<%
	String resource = "mybatis-config.xml";
	InputStream inputStream = Resources.getResourceAsStream(resource);
	SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
	SqlSession sqlsession=sqlSessionFactory.openSession();
	
	userMapper userMapper=sqlsession.getMapper(userMapper.class);
	productsMapper productsMapper=sqlsession.getMapper(productsMapper.class);
	
	List<user> user=userMapper.selectAllUser();
	List<user> loadInNum=userMapper.selectLoadInNum("统计网页访问次数");
	String stage1="确认收货";String stage2="待发货";String stage3="待收货";
	List<order> order1=productsMapper.selectOrderByStage(stage1);
	List<order> order2=productsMapper.selectOrderByStage(stage2);
	List<order> order3=productsMapper.selectOrderByStage(stage3);
	
	int confirmedOrder=0;int onSellOrder=0;int recievedOrder=0;
	for(order s:order1){confirmedOrder++;}for(order s:order2){onSellOrder++;}for(order s:order3){recievedOrder++;}
	int userNum=-1;//有个记录访问次数的记录条
	for(user s:user){userNum++;}
	int loadInTimes=0;
	for(user s:loadInNum){loadInTimes=s.getTime();}
	Date date=new Date();
	String time=(1900+date.getYear())+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
	int todayOrder=0;int allTimeOrder=0;int todayIncome=0;int doneIncome=0;int tradeIncome=0;
	List<order> allOrders=productsMapper.selectAllOrders();
	for(order s:allOrders){if(s.getOpentime().trim().contentEquals(time)){todayOrder++;todayIncome+=s.getAmount()*s.getPrice();}allTimeOrder++;}
	int productsNum=0;
	for(order s:allOrders){productsNum+=s.getAmount();if(s.getStage().trim().contentEquals("确认收货")){doneIncome+=s.getPrice()*s.getAmount();}else{tradeIncome+=s.getPrice()*s.getAmount();}}
	int average=(doneIncome+tradeIncome)/userNum;
	//4.执行方法
	request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");
	List<products> products=productsMapper.selectAll();
	int id=0;String img="";String name="";int price=0;int storage=0;int sold=0;int all_ordered=0;int status=0;String for_group="";String kind="";String statusDo="";
	%>
   <table id="tableProductsManage" border="0">
        <tr><td height="50px" width="150px" valign="bottom"><font style="color:blue;font-size:22px;font-weight:bolder;margin:10px;">|商品管理</font></td><td></td></tr>
        <tr><td rowspan="3"></td><td height="50px" width="1350px">&nbsp;&nbsp;<a style="margin-right:10px;" id="tableProductsManageA1" onClick="showAllProducts()">全部商品</a><a style="margin-right:10px;" id="tableProductsManageA2" onClick="showOnSellProducts()">上架商品</a><a style="margin-right:10px;" id="tableProductsManageA3" onClick="showNotOnSellProducts()">下架商品</a><a style="margin-right:10px;" id="tableProductsManageA4" onClick="showSoldOutProducts()">售罄商品</a>&nbsp;&nbsp;<a id="tableProductsManageA5" onClick="showAddProducts()" style="color:white;background-color:blueviolet;padding:8px;border-radius:6px">添加商品</a></td></tr>
        <tr><td height="60px" align="center"><form id="searchForm"><input id="inputSearchProducts" name="inputSearchProducts" placeholder="查询商品？输入商品名称或品类都能快速找到" type="text" style="width:500px;height:40px;border:2px solid black;border-radius:5px;background-color:rgb(0,0,0,0);font-size:16px;"><a id="tableProductsManageSearchButton" onClick="searchProducts()">查找</a>&nbsp;&nbsp;<a onClick="showAll()" style="background-color:white;padding:8px;border-radius:8px;">显示所有商品</a></form></td></tr>
        <tr><td align="center" valign="top" height="500px">
            <table id="tableAllProducts" border="0" cellspacing="5px" style="position:relative;left:50px;display:block;font-size:20px;">
                <tr align="center" style="font-size:20px;"><td height="50px" width="150px">商品图片</td><td width="250px">名称</td><td width="100px">价格（元）</td><td width="100px">库存（件）</td><td width="100px">销量</td><td width="100px">排序</td><td width="150px">状态</td><td width="200px">操作</td></tr>
            	<tr><td colspan="8"><hr></td></tr>
            	<%
            	String searchText=request.getParameter("inputSearchProducts");
            	if(searchText!=null){
            	for(products s:products){
            		img=s.getImg().trim();name=s.getName().trim();price=s.getPrice();storage=s.getStorage();sold=s.getSold();status=s.getStatus();all_ordered=s.getAll_ordered();for_group=s.getFor_group().trim();kind=s.getKind().trim();
            		if(kind.contentEquals("clothing") && for_group.contentEquals("m")){img="shopCenterImgs/man-clothing/"+img;}
            		else if(kind.contentEquals("clothing") && for_group.contentEquals("w")){img="shopCenterImgs/female-clothing/"+img;}
            		else if(kind.contentEquals("bag")){img="shopCenterImgs/bag/"+img;}
            		else if(kind.contentEquals("jewelry")){img="shopCenterImgs/jewelry/"+img;}
            		if(status==1){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=notSell&id="+id+"&name="+name+"'>下架</a>";}else if(status==0){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=onSell&id="+id+"&name="+name+"'>上架</a>";}            		
            		if(name.contains(searchText)){
                		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
            		}
            		if(searchText.contains("包") || searchText.contains("袋")){
    					if(kind.contentEquals("bag")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}else if(searchText.contains("男")){
    					if(kind.contentEquals("clothing") && for_group.contentEquals("m")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}else if(searchText.contains("衣") && searchText.contains("女")){
    					if(kind.contentEquals("clothing") && for_group.contentEquals("w")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}else if(searchText.contains("衣")){
    					if(kind.contentEquals("clothing")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}else if(searchText.contains("宝") || searchText.contains("钻") || searchText.contains("环") || searchText.contains("金") || searchText.contains("银") || searchText.contains("耳")){
    					if(kind.contentEquals("jewelry")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}else if(searchText.contains("女")){
    					if(for_group.contentEquals("w") || for_group.contentEquals("a")){
                    		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
    					}
    				}
            	}}else{
            	for(products s:products){
            		id=s.getId();img=s.getImg().trim();name=s.getName().trim();price=s.getPrice();storage=s.getStorage();sold=s.getSold();status=s.getStatus();all_ordered=s.getAll_ordered();for_group=s.getFor_group().trim();kind=s.getKind().trim();
            		if(kind.contentEquals("clothing") && for_group.contentEquals("m")){img="shopCenterImgs/man-clothing/"+img;}
            		else if(kind.contentEquals("clothing") && for_group.contentEquals("w")){img="shopCenterImgs/female-clothing/"+img;}
            		else if(kind.contentEquals("bag")){img="shopCenterImgs/bag/"+img;}
            		else if(kind.contentEquals("jewelry")){img="shopCenterImgs/jewelry/"+img;}
            		if(status==1){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=notSell&id="+id+"&name="+name+"'>下架</a>";}else if(status==0){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=onSell&id="+id+"&name="+name+"'>上架</a>";}
            		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
            	}}%>
            </table>
             <table id="tableOnSellProducts" border="0" cellspacing="5px" style="position:relative;left:50px;display:none;font-size:20px;">
                <tr align="center" style="font-size:20px;"><td height="50px" width="150px">商品图片</td><td width="250px">名称</td><td width="100px">价格（元）</td><td width="100px">库存（件）</td><td width="100px">销量</td><td width="100px">排序</td><td width="150px">状态</td><td width="200px">操作</td></tr>
            	<tr><td colspan="8"><hr></td></tr>
            	<div id="code">
            	<%for(products s:products){
            		id=s.getId();img=s.getImg().trim();name=s.getName().trim();price=s.getPrice();storage=s.getStorage();sold=s.getSold();status=s.getStatus();all_ordered=s.getAll_ordered();for_group=s.getFor_group().trim();kind=s.getKind().trim();
            		if(status==1){
            		if(kind.contentEquals("clothing") && for_group.contentEquals("m")){img="shopCenterImgs/man-clothing/"+img;}
            		else if(kind.contentEquals("clothing") && for_group.contentEquals("w")){img="shopCenterImgs/female-clothing/"+img;}
            		else if(kind.contentEquals("bag")){img="shopCenterImgs/bag/"+img;}
            		else if(kind.contentEquals("jewelry")){img="shopCenterImgs/jewelry/"+img;}
            		if(status==1){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=notSell&id="+id+"&name="+name+"'>下架</a>";}else if(status==0){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=onSell&id="+id+"&name="+name+"'>上架</a>";}
            		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
            		}}%></div>
            </table>
             <table id="tableNotOnSellProducts" border="0" cellspacing="5px" style="position:relative;left:50px;display:none;font-size:20px;">
                <tr align="center" style="font-size:20px;"><td height="50px" width="150px">商品图片</td><td width="250px">名称</td><td width="100px">价格（元）</td><td width="100px">库存（件）</td><td width="100px">销量</td><td width="100px">排序</td><td width="150px">状态</td><td width="200px">操作</td></tr>
            	<tr><td colspan="8"><hr></td></tr>
            	<%for(products s:products){
            		id=s.getId();img=s.getImg().trim();name=s.getName().trim();price=s.getPrice();storage=s.getStorage();sold=s.getSold();status=s.getStatus();all_ordered=s.getAll_ordered();for_group=s.getFor_group().trim();kind=s.getKind().trim();
            		if(status==0){
            		if(kind.contentEquals("clothing") && for_group.contentEquals("m")){img="shopCenterImgs/man-clothing/"+img;}
            		else if(kind.contentEquals("clothing") && for_group.contentEquals("w")){img="shopCenterImgs/female-clothing/"+img;}
            		else if(kind.contentEquals("bag")){img="shopCenterImgs/bag/"+img;}
            		else if(kind.contentEquals("jewelry")){img="shopCenterImgs/jewelry/"+img;}
            		if(status==1){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=notSell&id="+id+"&name="+name+"'>下架</a>";}else if(status==0){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=onSell&id="+id+"&name="+name+"'>上架</a>";}
            		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
            	}   }%>
            </table>
             <table id="tableSoldOutProducts" border="0" cellspacing="5px" style="position:relative;left:50px;display:none;font-size:20px;">
                <tr align="center" style="font-size:20px;"><td height="50px" width="150px">商品图片</td><td width="250px">名称</td><td width="100px">价格（元）</td><td width="100px">库存（件）</td><td width="100px">销量</td><td width="100px">排序</td><td width="150px">状态</td><td width="200px">操作</td></tr>
            	<tr><td colspan="8"><hr></td></tr>
            	<%for(products s:products){
           			id=s.getId();img=s.getImg().trim();name=s.getName().trim();price=s.getPrice();storage=s.getStorage();sold=s.getSold();status=s.getStatus();all_ordered=s.getAll_ordered();for_group=s.getFor_group().trim();kind=s.getKind().trim();
           			if(storage==0){
           			if(kind.contentEquals("clothing") && for_group.contentEquals("m")){img="shopCenterImgs/man-clothing/"+img;}
            		else if(kind.contentEquals("clothing") && for_group.contentEquals("w")){img="shopCenterImgs/female-clothing/"+img;}
            		else if(kind.contentEquals("bag")){img="shopCenterImgs/bag/"+img;}
            		else if(kind.contentEquals("jewelry")){img="shopCenterImgs/jewelry/"+img;}
            		if(status==1){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=notSell&id="+id+"&name="+name+"'>下架</a>";}else if(status==0){statusDo="<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=onSell&id="+id+"&name="+name+"'>上架</a>";}
            		out.println("<tr align='center'><td><img src='"+img+"' width='150px' height='150px'></td><td>"+name+"</td><td>"+price+"</td><td>"+storage+"</td><td>"+sold+"</td><td>"+all_ordered+"</td><td>"+statusDo+"</td><td>"+"<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' target='_blank' href='editProducts.jsp?id="+id+"'>编辑</a>&nbsp;<a style='padding:8px;font-size:18px;background-color:blueviolet;border-radius:8px;color:white;' href='ProductsManageServlet?do=remove&id="+id+"'>删除</a>"+"</td></tr><tr><td colspan='8'><hr style='color:rgb(0,0,0,0.5)'></td></tr>");
            	}   }%>
            </table>
            
   <table id="tableAddProducts" border="0" cellspacing="10px" style="display:none;">
   <form id="addProducts">
   <tr><td colspan="4" height="20px" ></tr>
	<tr><td align="right" rowspan="8" width="300px"></td><td width="180px" align="right">商品名称：</td><td width="500px"><input style="border-radius:6px;font-size:21px;width:200px;height:30px;border:0.5px solid black;background-color:rgb(0,0,0,0);" id="name" name="name" type="text"><span id="wrongName" style="color:red;display:none;">商品名称长度必须为2-20位</span></td><td rowspan="8" width="300px"></td></tr>
	<tr><td align="right">图片：</td><td><input placeholder="输入x.png并将图片放入指定地址即可" style="border-radius:6px;font-size:12px;width:200px;height:30px;border:0.5px solid black;background-color:rgb(0,0,0,0);" id="img" name="img" type="text"><span id="wrongImg" style="color:red;display:none;">请输入图片名称</span></td></tr>
	<tr><td align="right">价格：</td><td><input style="border-radius:6px;font-size:21px;width:200px;height:30px;border:0.5px solid black;background-color:rgb(0,0,0,0);" id="price" name="price" type="text"><span id="wrongPrice" style="color:red;display:none;">请输入一个大于等于0的数字</span></td></tr>
	<tr><td align="right">库存：</td><td><input style="border-radius:6px;font-size:21px;width:200px;height:30px;border:0.5px solid black;background-color:rgb(0,0,0,0);" id="storage" name="storage" type="text"><span id="wrongStorage" style="color:red;display:none;">请输入一个大于等于0的数字</span></td></tr>
	<tr><td align="right">排序：</td><td><input placeholder="数字越小，排行越靠前" style="border-radius:6px;font-size:16px;width:200px;height:30px;border:0.5px solid black;background-color:rgb(0,0,0,0);" id="all_ordered" name="all_ordered" type="text"><span id="wrongAllOrdered" style="color:red;display:none;">请输入一个大于等于0的数字</span></td></tr>
	<tr><td align="right">针对群体：</td><td><input type="radio" id="for1" name="for_group" value="a" checked="true"><label for="for1">全部</label><input type="radio" id="for2" name="for_group" value="w"><label for="for2">女性</label>
	<input type="radio" id="for3" name="for_group" value="m"><label for="for3">男性</label></td></tr>
	<tr><td align="right">种类：</td><td><input type="radio" id="kind1" name="kind" value="clothing" checked="true"><label for="kind1">服装</label><input type="radio" id="kind2" name="kind" value="bag"><label for="kind2">背包</label>
	<input type="radio" id="kind3" name="kind" value="jewelry"><label for="kind3">珠宝</label></td></tr>
	<tr><td></td><td><br><a onClick="submitAddProducts()" style="color:white;padding:8px;padding-left:15px;padding-right:15px;background-color:rgb(0,0,0,0.6);margin-right:20px;border-radius:8px;">添加</a></td></tr>
	<tr><td colspan="4" height="100px" align="center"></td></tr>
   	</form>
   </table>
	
    <script>
    	const name=document.getElementById("name");
    	const img=document.getElementById("img");
		const price=document.getElementById("price");
		const storage=document.getElementById("storage");
		const all_ordered=document.getElementById("all_ordered");
		name.onblur=checkName;price.onblur=checkPrice;storage.onblur=checkStorage;all_ordered.onblur=checkAll_ordered;img.onblur=checkImg;
		function checkName(){
			if(!(name.value.length>=2 && name.value.length<=20)){
				document.getElementById("wrongName").style.display="";return false;
			}else{document.getElementById("wrongName").style.display="none";return true;}
		}
		function checkImg(){
			if(!(img.value.length>0)){
				document.getElementById("wrongImg").style.display="";return false;
			}else{document.getElementById("wrongImg").style.display="none";return true;}
		}
		function checkPrice(){
			if(price.value>=0){
				document.getElementById("wrongPrice").style.display="none";return true;
			}else{document.getElementById("wrongPrice").style.display="";return false;}
		}
		function checkStorage(){
			if(storage.value>=0){
				document.getElementById("wrongStorage").style.display="none";return true;
			}else{document.getElementById("wrongStorage").style.display="";return false;}
		}
		function checkAll_ordered(){
			if(all_ordered.value>=0){
				document.getElementById("wrongAllOrdered").style.display="none";return true;
			}else{document.getElementById("wrongAllOrdered").style.display="";return false;}
		}
    	function submitAddProducts(){
    		if(checkName() && checkImg() && checkPrice() && checkStorage() && checkAll_ordered()){
    			document.getElementById("addProducts").method="post";document.getElementById("addProducts").action="ProductsManageServlet?do=addProducts";document.getElementById("addProducts").submit();
    			return true;
    		}else{
    			alert("数据有误，请检查");
    			return false;
    		}
    	}
    
        function showAllProducts(){showTextunderline("all");
        document.getElementById("tableAddProducts").style.display="none";document.getElementById("tableAllProducts").style.display="block"; document.getElementById("tableSoldOutProducts").style.display="none"; document.getElementById("tableOnSellProducts").style.display="none"; document.getElementById("tableNotOnSellProducts").style.display="none";}
        function showOnSellProducts(){showTextunderline("onSell");document.getElementById("tableAddProducts").style.display="none";document.getElementById("tableAllProducts").style.display="none"; document.getElementById("tableSoldOutProducts").style.display="none"; document.getElementById("tableOnSellProducts").style.display="block"; document.getElementById("tableNotOnSellProducts").style.display="none";}
        function showNotOnSellProducts(){showTextunderline("notOnSell");document.getElementById("tableAddProducts").style.display="none";document.getElementById("tableAllProducts").style.display="none"; document.getElementById("tableSoldOutProducts").style.display="none"; document.getElementById("tableOnSellProducts").style.display="none"; document.getElementById("tableNotOnSellProducts").style.display="block";}
        function showSoldOutProducts(){showTextunderline("soldOut");document.getElementById("tableAddProducts").style.display="none";document.getElementById("tableAllProducts").style.display="none"; document.getElementById("tableSoldOutProducts").style.display="block"; document.getElementById("tableOnSellProducts").style.display="none"; document.getElementById("tableNotOnSellProducts").style.display="none";}
        function showAddProducts(){showTextunderline("addP");document.getElementById("tableAddProducts").style.display="block";document.getElementById("tableAllProducts").style.display="none"; document.getElementById("tableSoldOutProducts").style.display="none"; document.getElementById("tableOnSellProducts").style.display="none"; document.getElementById("tableNotOnSellProducts").style.display="none";}
		function searchProducts(){const form=document.getElementById("searchForm");form.method="post";form.action="managerManageProducts.jsp";form.submit();}
        
        const a1= document.getElementById("tableProductsManageA1");const a2= document.getElementById("tableProductsManageA2");const a3= document.getElementById("tableProductsManageA3");const a4= document.getElementById("tableProductsManageA4");const a5= document.getElementById("tableProductsManageA5");
        a1.style.textDecorationLine="underline";a1.style.color="blue";
        function showTextunderline(a){
            if(a=="all"){
                a1.style.textDecorationLine="underline";a1.style.color="blue";
                a2.style.textDecorationLine="none";a2.style.color="black"; a3.style.textDecorationLine="none";a3.style.color="black"; a4.style.textDecorationLine="none";a4.style.color="black"; a5.style.textDecorationLine="none";a5.style.color="black";
                }
            else if(a=="onSell"){
                a2.style.textDecorationLine="underline";a2.style.color="blue";
                a1.style.textDecorationLine="none";a1.style.color="black"; a3.style.textDecorationLine="none";a3.style.color="black"; a4.style.textDecorationLine="none";a4.style.color="black"; a5.style.textDecorationLine="none";a5.style.color="black";
            }
            else if(a=="notOnSell"){
                a3.style.textDecorationLine="underline";a3.style.color="blue";
                a2.style.textDecorationLine="none";a2.style.color="black"; a1.style.textDecorationLine="none";a1.style.color="black"; a4.style.textDecorationLine="none";a4.style.color="black"; a5.style.textDecorationLine="none";a5.style.color="black";
            }
            else if(a=="soldOut"){
                a4.style.textDecorationLine="underline";a4.style.color="blue";
                a2.style.textDecorationLine="none";a2.style.color="black"; a3.style.textDecorationLine="none";a3.style.color="black"; a1.style.textDecorationLine="none";a1.style.color="black"; a5.style.textDecorationLine="none";a5.style.color="black";
            }
            else if(a=="addP"){
                a5.style.textDecorationLine="underline";a5.style.color="blue";
                a2.style.textDecorationLine="none";a2.style.color="black"; a3.style.textDecorationLine="none";a3.style.color="black"; a4.style.textDecorationLine="none";a4.style.color="black"; a1.style.textDecorationLine="none";a1.style.color="black";}
        	}
        
        function showAll(){window.location.href="managerManageProducts.jsp";}
        function editProducts(){}
        
    </script>

</body>
</html>